package com.gxwz.document.business.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.gxwz.document.business.dao.IuserDao;
import com.gxwz.document.business.entity.User;
import com.gxwz.document.core.dao.impl.BaseDaoImpl;
@Repository("userDao")
public class UserDaoImpl extends BaseDaoImpl<User> implements IuserDao {

	@Override
	public List<User> findAll() {
		String hql = "from User where 1=1";
		return this.find(hql);
	}
    
	@Override
	public List<User> findbyOrder(User user, int index, int pageSize) {
		String hql = "from User where 1=1";
		if(null != user.getUserLoginName()){
			hql = "from User u where u.userLoginName like '%"+user.getUserLoginName()+"%'";
			if(null != user.getUserName()){
				hql = "from User u where u.userName like '%"+user.getUserName()+"%' and u.userLoginName like '%"+user.getUserLoginName()+"%'";
			}
		}else if(null != user.getUserName()){
			hql = "from User u where u.userName like '%"+user.getUserName()+"%'";
		}

		System.out.println(hql);
		return this.findByPage(hql, index, pageSize);
	}



	
}
